import java.util.Calendar;
import java.lang.Integer;
public class attribute extends fabrikat
{
	private int groesse;
	private String farbe;
	private Calendar date;
	private int year;
	private int day;
	private int month;
	private String[] datestringarray;
	private static int totalstock;
	private static boolean emptystock;
	
	public void setFarbe(String farbe)
	{
		this.farbe = farbe;
	}
	
	public void emptyStock()
	{
		this.emptystock = true;
	}
	
	public void fullStock()
	{
		this.emptystock = false;
	}
	
	public boolean getStockStatus()
	{	
		return emptystock;
	}
	
	public void setGroesse(int groesse)
	{
		this.groesse = groesse;
	}
	
	public void changeTotalStock()
	{
		totalstock -= 1;
	}
	
	public String getFarbe()
	{
		return farbe;
	}
	
	public int getGroesse()
	{
		return groesse;
	}
	
	public int getTotalstock()
	{
		return totalstock;
	}
	
	attribute(int id, String hersteller, String fabrikat, int groesse, String farbe, Calendar Date)
	{
		super(id, hersteller, fabrikat);
		this.groesse = groesse;
		this.farbe = farbe;
		setDate(Date);
		totalstock += 1;
		fullStock();
		
	}
	
	attribute(int id, String hersteller, String fabrikat, int groesse, String farbe, String Date)
	{
		super(id,hersteller,fabrikat);
		this.groesse = groesse;
		this.farbe = farbe;
		convertStringDate(Date);
		totalstock += 1;
		fullStock();
	}
	
	public void convertStringDate(String Date)
	{
		String[] tmparray;
		
		tmparray = Date.split("-",3);
		this.year = Integer.parseInt(tmparray[0]);
		this.month = Integer.parseInt(tmparray[1]);
		this.day = Integer.parseInt(tmparray[2]);
	}
	
	attribute()
	{
	}
	
	public Calendar getDate()
	{
		return date;
	}
	
	public void setDate(Calendar date)
	{
		this.date = date;
		if(getDay() == 0 && getMonth() == 0 && getYear() == 0)
		convert(this.date);		
	}	
	
	public void convert(Calendar date)
	{
		String datestring = String.format("%tF%n",date);
		String delimiter = "-";
		int strings = 3;		
		String[] datestringarray= datestring.split(delimiter,strings);
		this.datestringarray = datestringarray;
	
		datestringarray[2] = datestringarray[2].substring(0,2);
		
		this.day = Integer.parseInt(datestringarray[2]);	
		this.month = Integer.parseInt(datestringarray[1]);
		this.year = Integer.parseInt(datestringarray[0]);
	}
	
	public void setYear(int year)
	{
		this.year = year;
	}
	
	public int getYear()
	{
		return year;
	}
	
	public int getMonth()
	{
		return month;
	}
	
	public void setMonth(int month)
	{
		this.month = month;
	}
	
	public void setDay(int day)
	{
		this.month = month;
	}
	
	public int getDay()
	{
		return day;
	}
	
	

}
